using System.Collections;
using System.Collections.Generic;
using System.IO;
using cfg;
using SimpleJSON;
using UnityEngine;

namespace QFramework.Monk
{
    public enum GameState
    {
        GameStart,
        GamePlaying,
        GameOver,
        GamePass
    }
    
    public enum AbilityType
    {
        Exp=1,
        Coin=2,
        MaxHp=3,
        Attack=4,
    }
    
    
    public class AppStart:Architecture<AppStart>
    {
        public static BindableProperty<int> exp =new BindableProperty<int>(0);
        
        public  static BindableProperty<float> curSec =new BindableProperty<float>(0);
        
        public static BindableProperty<int> level =new BindableProperty<int>(0);
        
        public static BindableProperty<float> damage =new BindableProperty<float>(1);
        
        public static BindableProperty<float> ackDuration =new BindableProperty<float>(1.5f);
        
        public  static BindableProperty<int> playerSpeed =new BindableProperty<int>(5);
        
        public static BindableProperty<int> enemyNum =new BindableProperty<int>(0);
        
        public static BindableProperty<int> curHp =new BindableProperty<int>(3);
        
        public static BindableProperty<int> maxHp =new BindableProperty<int>(3);
        
        public static BindableProperty<GameState> gameState =new BindableProperty<GameState>(GameState.GameStart);
        
        public static  BindableProperty<int> goldNum =new BindableProperty<int>(0);
        
        public static  BindableProperty<int>  expDropLv = new BindableProperty<int>(0);
        
        public static  BindableProperty<int>  coinDropLv = new BindableProperty<int>(0);
        
        public static  BindableProperty<int>  hpLv = new BindableProperty<int>(0);
        
        public static   BindableProperty<int>  attackLv = new BindableProperty<int>(0);
        
        public static   BindableProperty<float> expDropPrecent   = new BindableProperty<float>(0.7f);
        
        public static   BindableProperty<float> coinDropPrecent   = new BindableProperty<float>(0.5f);
        
        
        //固定值
        public static   BindableProperty<float> hpDropPrecent   = new BindableProperty<float>(0.3f);
        
        public static BindableProperty<float> getAllExpPrecent =new BindableProperty<float>(0.3f);
        
        public static BindableProperty<float> bombPrecent =new BindableProperty<float>(0.2f); 
        
        //局内技能等级
        public static BindableProperty<int> attackSkillLv =new BindableProperty<int>(0);
        public static BindableProperty<int> attackCdSkillLv =new BindableProperty<int>(0);
        public  static BindableProperty<int> speedSkillLv =new BindableProperty<int>(0);
        
        public static void RestData()
        {
            exp.Value = 0;
            curSec.Value = 0;
            level.Value = 0;
            damage.Value = PlayerPrefs.GetFloat("damage", 1f);
            ackDuration.Value = 1.5f;
            playerSpeed.Value = 4;
            curHp.Value = maxHp.Value;
            attackSkillLv.Value = 0;
            attackCdSkillLv.Value = 0;
            speedSkillLv.Value = 0;
            
        }

        [RuntimeInitializeOnLoadMethod]
        public static void InitData()
        {
            AudioKit.PlaySoundMode = AudioKit.PlaySoundModes.IgnoreSameSoundInGlobalFrames;
            ResKit.Init();
            //PlayerPrefs.SetInt("goldNum", 13);
            goldNum.Value = PlayerPrefs.GetInt("goldNum", 0);
            
            coinDropLv.Value = PlayerPrefs.GetInt("coinDropLv", 0);
            expDropLv.Value = PlayerPrefs.GetInt("expDropLv", 0);
            hpLv.Value = PlayerPrefs.GetInt("hpLv", 0);
            attackLv.Value = PlayerPrefs.GetInt("attackLv", 0);
            expDropPrecent.Value = PlayerPrefs.GetFloat("expDropPrecent", 0.7f);
            coinDropPrecent.Value = PlayerPrefs.GetFloat("coinDropPrecent", 0.5f);
            damage.Value = PlayerPrefs.GetFloat("damage", 1f);
            
            maxHp.Value = PlayerPrefs.GetInt("maxHp", 5);
            curHp.Value = maxHp.Value;
        }

        public static void ChangeGameState(GameState state)
        {
            gameState.Value = state;
        }

        public static bool CheckGameState(GameState state)
        {
            return gameState.Value == state;
        }

        protected override void Init()
        {
            
            ResKit.Init();
            
            this.RegisterSystem(new CoinUpSystem());
            this.RegisterSystem(new GenerateItemSystem());
            this.RegisterSystem(new WaveSystem());
            this.RegisterSystem(new ExpUpSystem());
            this.RegisterModel(new ConfigModel());
            
            
            
        }
        
        
    }
    
}
